<template>
	<view class="container">
		
		<view class="reportView">
			<uni-row class="uni-row">
				<uni-col>
					<text class="title">活动名称</text>
					<view class="input-item flex align-center">
					  <input v-model="FormData.activityName"  placeholder="请输入活动名称"  placeholder-class="place"  class="input" type="text"  maxlength="30" />
					</view>
				</uni-col>
			</uni-row>
			<uni-row class="uni-row">
				<uni-col :span="12">
					<text class="title">开始时间</text>
					<view class="input-item flex align-center">
					  <uni-data-select
					  v-model="FormData.type"
					  :localdata="range"
					  @change="change"
					></uni-data-select>
					</view>
				</uni-col>
				<uni-col :span="12">
					<text class="title">结束时间</text>
					<view class="input-item flex align-center">
					  <uni-data-select
					    v-model="FormData.status"
					    :localdata="range2"
					    @change="change"
					  ></uni-data-select>
					</view>
				</uni-col>
			</uni-row>
			<uni-row class="uni-row">
				<uni-col :span="12">
					<text class="title">活动状态</text>
					<view class="input-item flex align-center">
					  <uni-data-select
					    v-model="FormData.status"
					    :localdata="range2"
					    @change="change"
					  ></uni-data-select>
					</view>
				</uni-col>
			</uni-row>
			<uni-row class="uni-row">
				<uni-col>
					<text class="title">活动内容</text>
					<view class="input-item textarea-item flex align-center">
						<textarea class="textarea"  v-model="FormData.content" placeholder="请输入注意事项"  placeholder-class="place"   id="" cols="30" rows="10"></textarea>
					  <!-- <input v-model="FormData.categoryDesc" class="input" type="text"  maxlength="30" /> -->
					</view>
				</uni-col>
			</uni-row>
			<uni-row class="uni-row">
				<uni-col>
					<text class="title">活动封面</text>
					<view class="uploadView">
					  <uni-file-picker limit="1" class="">
						  <text>添加封面</text>
					  </uni-file-picker>
					</view>
				</uni-col>
			</uni-row>
		</view>
		<view class="submit-view">
			<button class='submit'  @tap="clickBtn">完成</button>
		</view>
	</view>
</template>
<script>
	import { getActivityById,updateCate } from '@/api/exam/activity.js'
	export default{
		data(){
			return{
				id:null,
				range:[{
					text:'公有',
					value:0
				},{
					text:'私有',
					value:1
				}],
				range2:[{
					text:'未发布',
					value:0
				},{
					text:'已发布',
					value:1
				}],
				FormData:{
					parentId:1,
					categoryName:null,
					categoryDesc:null,
					sort:1,
					status:null,
					type:null,
					photoUrl:null
				}
				
			}
		},
		onLoad(e) {
			if(e.id != null && e.id != ''){
				this.id = e.id
				this.getData();
			}
		},
		created() {
			
		},
		methods:{
			clickToBank(){
				this.$tab.navigateTo(`/pages/work/exam/questionBank`)
			},
			change(e) {
			},
			getData(){
				let data={
					id:this.id
				}
				getActivityById(data).then(res=>{
					this.FormData = res.data
				})
			},
			clickBtn(){
				updateCate(this.FormData).then(res=>{
					if(res.data === true){
						uni.navigateBack({
							delta:1
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.container{
		background-color: #fff;
		height: 100vh;
		.reportView{
			width: calc(100% - 80rpx);
			margin: 0 auto;
			.title{
				font-size: 14px;
				font-family: Inter-Bold, Inter;
				font-weight: bold;
				color: #000000;
				line-height: 40px;
			}
			.textarea{
				
			}
			
			.input-item{
				background-color: #ffffff;
				height: 30px;
				border-radius: 5px 5px 5px 5px;
				opacity: 1;
				border: 1px solid #508CFF;
				padding: 20px 10px;
				margin-left: 10px;
				.place{
					font-size: 12px;
				}
				/deep/ .uni-select{
					border: none;
					border-bottom: none;
					padding-left: 0;
				}
			}
			.textarea-item{
				height: 125px;
				.place{
					padding: 20px 0;
				}
				/deep/ .uni-textarea-textarea{
					padding-top: 20px;
				}
			}
			.uploadView{
				 margin: 10rpx 20epx;
				/deep/ .uni-file-picker{
					width: 230rpx !important;
				
				 }
				/deep/ .file-picker__box{
					 width: 200rpx !important;
					 height: 200rpx !important;
					 background: #F0EFEF;
					 color: #969696;
					 font-size: 12px;
					 border-radius: 20rpx;
				 }
			}
			.uni-row{
				margin-bottom: 10px;
			}
			
		}
		.submit{
			color: #fff;
			width: 100px;
			height: 40px;
			font-size: 14px;
			line-height: 40px;
			background: #508CFF;
			border-radius: 5px 5px 5px 5px;
			position: absolute;
			bottom: 50px;
			left: 36%;
		}
	}
</style>